---
description: "Reference for Nitric's Go library - Delete a file from a bucket."
---

# Go - Bucket.File.Delete()

<Note>
  This is reference documentation for the Nitric Go SDK. To learn about Storage
  and Buckets in Nitric start with the [Storage docs](/storage).
</Note>

Delete a file from a bucket.

```go
import (
  "context"

  "github.com/nitrictech/go-sdk/nitric"
  "github.com/nitrictech/go-sdk/nitric/storage"
)

func main() {
  bucket := nitric.NewBucket("bucket-name").Allow(storage.BucketDelete)

  err := bucket.Delete(context.TODO(), "cat.png")
  if err != nil {
    return
  }

  nitric.Run()
}
```

## Parameters

<Properties>
  <Property name="ctx" required type="context">
    The context of the call, used for tracing.
  </Property>
  <Property name="key" required type="string">
    The key of the file to delete.
  </Property>
</Properties>

## Examples

### Delete a file

```go
import (
  "context"

  "github.com/nitrictech/go-sdk/nitric"
  "github.com/nitrictech/go-sdk/nitric/storage"
)

func main() {
  bucket := nitric.NewBucket("bucket-name").Allow(storage.BucketDelete)

  err := bucket.Delete(context.TODO(), "cat.png")
  if err != nil {
    return
  }

  nitric.Run()
}
```
